import {takeEvery,put} from 'redux-saga/effects';
import {GET_INIT_LIST} from './actionType';
import axios from 'axios';
import {initListAction} from './actionCreators';

//实时的处理异步数据
function* getInitList(){
    try{
        const res=yield axios.get('http://localhost/list.json');
        const action = initListAction(res.data);
        yield put(action);
    }catch(e){
        
    }
    

}

//generator函数
 function* todoSagas(){
    //只要接受到GET_INIT_LIST这个变量就执行fetchUser方法
    yield takeEvery(GET_INIT_LIST,getInitList);
}

export default todoSagas;

